import { Schemas } from '@/types/domain_models'
import TianzhiJavaGenerator from '.'
import { sep } from 'path'

export function writing(generator: TianzhiJavaGenerator, packageName: string, schemas: Schemas) {
  const tpl = generator.templatePath(`controller${sep}controller.java.ejs`)

  Object.values(schemas).forEach((schema) => {
    generator.fs.copyTpl(
      tpl,
      generator._classFilePath(`controller${sep}${schema.upperFirstCamelCaseName}Controller.java`),
      {
        packageName,
        snakeCameName: schema.snakeCameName,
        upperFirstCamelCaseName: schema.upperFirstCamelCaseName,
        camelCaseName: schema.camelCaseName,
        kebabCaseName: schema.kebabCaseName,
        properties: schema.properties,
      }
    )
  })
}
